// 委托类型：成绩打印

public delegate void GradePrint(Student s);

// 学生类

public class Student

{

    public string Name { get; set; }

    public double Score { get; set; }

    public GradePrint GP { get; set; } // 委托属性

}

// 成绩单类

public class GradeReport

{

    public static void PrintByTerm(Student s)

    {

        Console.WriteLine($"【学期成绩单】学生：{s.Name}，成绩：{s.Score}");

    }

    public static void PrintByRank(Student s)

    {

        Console.WriteLine($"【排名成绩单】学生：{s.Name}，成绩：{s.Score}");

    }

}

// 测试类

class Program

{

    static void Main()

    {

        Student student = new Student { Name = "王五", Score = 90 };

        // 选择打印模板

        student.GP = GradeReport.PrintByTerm;

        student.GP(student);

        student.GP = GradeReport.PrintByRank;

        student.GP(student);

    }

}


